import { ILoadMapTypeAll } from '@/common';
import { ManageCommonAPI } from '@/pages/type';
import { getSelectDataMapList, getTenantID } from '@/utils';

/** 材料列表搜索 */
const getMaterialSearchList = (loadInfo: Record<string, any>): ManageCommonAPI.ISearchList => {
  /**材料类型数据字典*/
  // const materialTypeMapList = loadInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`];
  const materialTypeMapList = getSelectDataMapList(loadInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`], 'name', 'id', true);

  return [
    {
      name: 'fullName',
      placeholder: '名称',
      label: '名称',
      componentType: 'Input',
      allowClear: true,
      md: 8,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'materialType',
      placeholder: '类型',
      label: '类型',
      componentType: 'TreeSelect',
      dataSource: materialTypeMapList,
      allowClear: true,
      md: 8,
      sm: 24,
      whetherSenior: false,
      treeID: 'id',
      treeName: 'name',
    },
  ];
};

export { getMaterialSearchList };
